Artificial Neural Network Regression
Artificial Neural Network (ANN) regression is a technique used in machine learning to solve regression problems. Regression refers to the task of predicting a continuous numerical value, such as predicting house prices, stock prices, or the age of a person based on certain input variables or features.
ANNs are computational models inspired by the structure and function of the human brain. They consist of interconnected nodes, or artificial neurons, organized into layers. The three main types of layers in an ANN are the input layer, hidden layers, and output layer.
Method: POST Authorization: API Keyhttps://engine.raccoon-ai.io/api/v1/ml/regression/ann
Authorization
Type | Key | Value |
---|---|---|
API Key | X-Api-Key | rae_###### |
Request Body
Section | Key | Data Type | Required | Description |
---|---|---|---|---|
train | data | json | true | Data that use to train the model |
features | list | true | Input features (X) | |
targets | list | true | Output targets (y) | |
config | json | false | Train configurations | |
predict | data | json | true | Data that need to predicted by the trained model |
config | json | false | Predict configurations |
Data Types
{
"train" : {
"data" : <json_data>,
"features": <list>,
"targets" : <list>,
"config" : {
"encoder": <"onehot" | "label" | "drop">,
"std_scale": boolean,
"hidden_units": list,
"val_size" : <float>
}
},
"predict": {
"data": <json_data>,
"config": {
"include_inputs": <boolean>,
"round": <int>
}
}
}
Hyper Parameters
Parameter | Type | Default | Description |
---|---|---|---|
activation | <identity | logistic | tanh | relu > | relu | Activation function for the hidden layer. ‘identity’, no-op activation, useful to implement linear bottleneck, returns f(x) = x ‘logistic’, the logistic sigmoid function, returns f(x) = 1 / (1 + exp(-x)). ‘tanh’, the hyperbolic tan function, returns f(x) = tanh(x). ‘relu’, the rectified linear unit function, returns f(x) = max(0, x) |
solver | <lbfgs | sgd | adam > | adam | The solver for weight optimization. ‘lbfgs’ is an optimizer in the family of quasi-Newton methods. ‘sgd’ refers to stochastic gradient descent. ‘adam’ refers to a stochastic gradient-based optimizer proposed by Kingma, Diederik, and Jimmy Ba Note: The default solver ‘adam’ works pretty well on relatively large datasets (with thousands of training samples or more) in terms of both training time and validation score. For small datasets, however, ‘lbfgs’ can converge faster and perform better. |
alpha | <auto | int> | auto | Strength of the L2 regularization term. The L2 regularization term is divided by the sample size when added to the loss. |
batch_size | <auto | int> | auto | Size of minibatches for stochastic optimizers. If the solver is ‘lbfgs’, the regressor will not use minibatch. When set to “auto”, batch_size=min(200, n_samples) |
learning_rate | <constant | invscaling | adaptive > | constant | Learning rate schedule for weight updates. ‘constant’ is a constant learning rate given by ‘learningrate_init’. ‘invscaling’ gradually decreases the learning rate learning_rate at each time step ‘t’ using an inverse scaling exponent of ‘power_t’. effective_learning_rate = learning_rate_init / pow(t, power_t) ‘adaptive’ keeps the learning rate constant to ‘learning_rate_init’ as long as training loss keeps decreasing. Each time two consecutive epochs fail to decrease training loss by at least tol, or fail to increase validation score by at least tol if ‘early_stopping’ is on, the current learning rate is divided by 5. Only used when solver=’sgd’. |
learning_rate_init | float | 0.001 | The initial learning rate used. It controls the step-size in updating the weights. Only used when solver=’sgd’ or ‘adam’. |
power_t | float | 0.5 | The exponent for inverse scaling learning rate. It is used in updating effective learning rate when the learning_rate is set to ‘invscaling’. Only used when solver=’sgd’. |
max_iter | int | 200 | Maximum number of iterations. The solver iterates until convergence (determined by ‘tol’) or this number of iterations. For stochastic solvers (‘sgd’, ‘adam’), note that this determines the number of epochs (how many times each data point will be used), not the number of gradient steps. |
shuffle | boolean | True | Whether to shuffle samples in each iteration. Only used when solver=’sgd’ or ‘adam’. |
random_state | <int | None> | None | Determines random number generation for weights and bias initialization, train-test split if early stopping is used, and batch sampling when solver=’sgd’ or ‘adam’. Pass an int for reproducible results across multiple function calls. |
tol | float | 0.0001 | Tolerance for the optimization. When the loss or score is not improving by at least tol for n_iter_no_change consecutive iterations, unless learning_rate is set to ‘adaptive’, convergence is considered to be reached and training stops. |
warm_start | boolean | False | When set to True, reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution. |
momentum | float | 0.9 | Momentum for gradient descent update. Should be between 0 and 1. Only used when solver=’sgd’. |
nesterovs_momentum | boolean | True | Whether to use Nesterov’s momentum. Only used when solver=’sgd’ and momentum > 0. |
early_stopping | boolean | False | Whether to use early stopping to terminate training when validation score is not improving. If set to True, it will automatically set aside validation_fraction of training data as validation and terminate training when validation score is not improving by at least tol for n_iter_no_change consecutive epochs. Only effective when solver=’sgd’ or ‘adam’. |
validation_fraction | float | 0.1 | The proportion of training data to set aside as validation set for early stopping. Must be between 0 and 1. Only used if early_stopping is True. |
beta_1 | float | 0.9 | Exponential decay rate for estimates of first moment vector in adam, should be in [0, 1). Only used when solver=’adam’. |
beta_2 | float | 0.999 | Exponential decay rate for estimates of second moment vector in adam, should be in [0, 1). Only used when solver=’adam’. |
epsilon | float | 1e-8 | Value for numerical stability in adam. Only used when solver=’adam’. |
n_iter_no_change | int | 15000 | Maximum number of epochs to not meet tol improvement. Only effective when solver=’sgd’ or ‘adam’. |
max_fun | int | 15000 | Only used when solver=’lbfgs’. Maximum number of function calls. The solver iterates until convergence (determined by tol), number of iterations reaches max_iter, or this number of function calls. Note that number of function calls will be greater than or equal to the number of iterations for the ANN regressor. |
Sample
{
"train": {
"data": {
"R&D Spend": {
"0": 165349.2,
"1": 162597.7,
"2": 153441.51,
"3": 144372.41,
"4": 142107.34,
"5": 131876.9,
"6": 134615.46,
"7": 130298.13,
"8": 120542.52,
"9": 123334.88
},
"Administration": {
"0": 136897.8,
"1": 151377.59,
"2": 101145.55,
"3": 118671.85,
"4": 91391.77,
"5": 99814.71,
"6": 147198.87,
"7": 145530.06,
"8": 148718.95,
"9": 108679.17
},
"Marketing Spend": {
"0": 471784.1,
"1": 443898.53,
"2": 407934.54,
"3": 383199.62,
"4": 366168.42,
"5": 362861.36,
"6": 127716.82,
"7": 323876.68,
"8": 311613.29,
"9": 304981.62
},
"State": {
"0": "New York",
"1": "California",
"2": "Florida",
"3": "New York",
"4": "Florida",
"5": "New York",
"6": "California",
"7": "Florida",
"8": "New York",
"9": "California"
},
"Profit": {
"0": 192261.83,
"1": 191792.06,
"2": 191050.39,
"3": 182901.99,
"4": 166187.94,
"5": 156991.12,
"6": 156122.51,
"7": 155752.6,
"8": 152211.77,
"9": 149759.96
}
},
"features": ["R&D Spend", "Administration", "Marketing Spend", "State"],
"targets": ["Profit"],
"config": {
"encoder": "onehot",
"std_scale": true,
"hidden_units": [100, 100],
"max_iter": 1000
}
},
"predict": {
"data": {
"R&D Spend": {
"0": 165349.2,
"1": 162597.7
},
"Administration": {
"0": 136897.8,
"1": 151377.59
},
"Marketing Spend": {
"0": 471784.1,
"1": 443898.53
},
"State": {
"0": "New York",
"1": "California"
}
},
"config": {
"include_inputs": true,
"round": 2
}
}
}
Train config
Reponse Body
Key | Data Type | Description |
---|---|---|
success | boolean | Indicate the success of the request |
msg | string | Message indicators |
error | string | Error information, only set if success is false |
result | json | result, only set if success is true |
score | json | r2_scores of the training and testing phases, only set if success is true |
generated_ts | float | generated timestamp |
Data Types
{
"success": <boolean>,
"msg": <string>,
"error": <string>,
"result": <json>,
"score": {
"train": <float>,
"test": <float>
},
"generated_ts": <timestamp>
}
Sample
{
"success": true,
"msg": "Model trained and predicted successfully",
"error": null,
"result": {
"R&D Spend": {
"0": 165349.2,
"1": 162597.7
},
"Administration": {
"0": 136897.8,
"1": 151377.59
},
"Marketing Spend": {
"0": 471784.1,
"1": 443898.53
},
"State": {
"0": "New York",
"1": "California"
},
"Profit": {
"0": 190209.72,
"1": 186863.18
}
},
"score": {
"train": 0.942446542689397,
"test": 0.9649618042060305
},
"saved_in": null,
"generated_ts": 1685439220.425382
}